<?php
session_start();
require_once("../config/include_tokyo.inc.php");

//访问权限验证
$userRole = $_SESSION['user_role'];
if($userRole == 1 || $userRole == 8){
	//管理员+团队成员
}else{
	if($userRole > 0){
		$url = "../index.php?loginError=2";//没权限
	}else{
		$url = "../index.php?loginError=3";//没登录
	}	
	echo "<script language='javascript' type='text/javascript'>";
	echo "window.location.href='$url'";
	echo "</script>";
}


//获取form值
$action = $_POST["action"];	
$transID = $_POST["id"];
$order_id = $_POST["order_id"];	
$chinese_content = $_POST["chinese_content"];
$english_content = $_POST["english_content"];
$japanese_content = $_POST["japanese_content"];
$trans_type = $_POST["trans_type"];
$trans_type_1 = "";
$trans_type_2 = "";
$trans_type_3 = "";

$currentTitle = "新增翻译";
if($action == "add"){
	$currentTitle = "新增翻译";
}else if($action == "edit"){
	$currentTitle = "编辑翻译";
	$sql_select = "SELECT * from translate t where t.id = $transID ";
	$result = $db->Execute($sql_select);
	while (!$result->EOF) {
		$order_id = $result->fields['order_id'];
		$chinese_content = $result->fields['chinese_content'];
		$english_content = $result->fields['english_content'];
		$japanese_content = $result->fields['japanese_content'];
		$trans_type = $result->fields['type'];
		$result->MoveNext();
	}
	echo "编辑内容 ID:$transID";
}else if($action == "save"){	
	if($transID == ""){
		$currentTitle = "新增翻译成功!";
		$sql = "INSERT INTO translate (order_id,chinese_content,english_content,japanese_content,type) VALUES ($order_id,'$chinese_content','$english_content','$japanese_content',$trans_type)";
		$db->Execute($sql);	
	}else{
		$currentTitle = "修改翻译成功!";
		$sql = "update translate set order_id=$order_id,chinese_content='$chinese_content',english_content='$english_content',japanese_content='$japanese_content',type=$trans_type   where id=".$transID;
		$db->Execute($sql);
	}	
	$showSuccess = "***************************************<br>";
	$showSuccess = $showSuccess."OrderID:".$order_id."<br>";
	$showSuccess = $showSuccess."中文内容:".$chinese_content."<br>";
	$showSuccess = $showSuccess."英文内容:".$english_content."<br>";
	$showSuccess = $showSuccess."日文内容:".$japanese_content."<br>";
	$showSuccess = $showSuccess."内容类型:".$trans_type."<br>";
	$showSuccess = $showSuccess."***************************************<br>";
	echo $showSuccess;

	
}


if($trans_type == "1"){
	$trans_type_1 =  "selected";
}else if($trans_type == "2"){
	$trans_type_2 =  "selected";
}else if($trans_type == "3"){
	$trans_type_3 =  "selected";
}else{
	$trans_type_1 =  "selected";
}





?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<!--Begin:head-->
<? $pageTitle = "翻译详情"; ?>
<?php include("../head.php"); ?>
<!--End:head-->


<body>
<?php include("../topMenu.php"); ?>


<form name="inputForm" action="../trans/transInput.php" method="post">
<div id="container" >	
<div class="grayTable">	

<table >
	<tr>
		<td align="right">排序编号:</td>
		<td align="left"><input type="text" name="order_id" id="order_id" size=5 value="<?php echo $order_id; ?>"></td>
	</tr>			
	<tr>
		<td align="right">中文内容:</td>
		<td align="left">
			<textarea cols="100" rows="5" id="chinese_content" name="chinese_content" ><?php echo $chinese_content; ?></textarea>
		</td>
	</tr>	
	<tr>
		<td align="right">英文内容:</td>
		<td align="left">
			<textarea cols="100" rows="5" id="english_content" name="english_content" ><?php echo $english_content; ?></textarea>
		</td>
	</tr>
	<tr>
		<td align="right">日文内容:</td>
		<td align="left">
			<textarea cols="100" rows="5" id="japanese_content" name="japanese_content" ><?php echo $japanese_content; ?></textarea>
		</td>
	</tr>
	<tr>
		<td align="right">内容类型:</td>
		<td align="left">
		<select name="trans_type" id="trans_type">
			<option value=1  <?php echo $trans_type_1; ?>>邮件翻译</option>
			<option value=2  <?php echo $trans_type_2; ?>>短文翻译</option>
			<option value=3  <?php echo $trans_type_3; ?>>长段翻译</option>
		</select>
		</td>
	</tr>
	<tr>
		<td colspan=2 align="right"><input type="submit" value="保存"></td>
	</tr>					
</table>
<br>
<a href="transList.php">翻译列表</a>
</div>
<input type="hidden" name="id" id="id" value="<?php echo $transID;?>">	
<input type="hidden" name="action" id="action" value="save">

<br><br>
<br><br>

</div><!--end container -->


</form>
</body>




</html>

<script>

</script>

